<?php
class TagController extends MController {
    public function indexAction(){
        
    }

    public function loadAction(){
        if ($this->getRequest()->isAjax()){
            $this->renderPartial();
        } else {
            $this->render();
        }
    }

    public function showAction(){
        if ($this->getRequest()->isAjax()){
            if ($this->getRequest()->isPost()){
                $postData = $this->getRequest()->getPost();
                $tagName = $postData['tag'];
                $tag = Tag::find_by_tag($tagName);
                if ($tag != NULL){
                    $posts = $tag->posts;
                }
            }
            $this->renderPartial('show',array('tag'=>$tag, 'posts'=>$posts));
        } else {
            if ($this->getRequest()->isPost()){
                $postData = $this->getRequest()->getPost();
                $tagName = $postData['tag'];
                $tag = Tag::find_by_tag($tagName);
                if ($tag != NULL){
                    $posts = $tag->posts;
                }
            }
            $this->render('show',array('tag'=>$tag, 'posts'=>$posts));
        }
    }
}
?>
